import { Table } from '../db/index.js'

const tb_jobs = new Table('jobs')

export const fetchJobs = async () => {
  const jobs = await tb_jobs.select()
  return jobs
}


export const fetchDetailJobs = async () => {
  const jobs = await tb_jobs.selectConditional({
    detailState: 0
  })
  return jobs
}

export const updateDetailJobs = async (jobs: any) => {
  jobs.detailState = 1
  await tb_jobs.updateById(jobs)
}

export const fetchCompanyJobs = async () => {
  const jobs = await tb_jobs.selectConditional({
    companyState: 0
  })
  return jobs
}

export const updateCompanyJobs = async (jobs: any) => {
  jobs.companyState = 1
  await tb_jobs.updateById(jobs)
}